package com.example.bijiabao.controller;

import com.example.bijiabao.entity.book;
import com.example.bijiabao.services.BookServices;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/bk")
public class BookController {
    @Autowired
    private BookServices bookServices;

    @GetMapping("/list")
    public List<book> getAllClass(){
        return bookServices.getAllBook();
    }
    @GetMapping("/list1/{num}")//童书
    public PageInfo<book> findbookById1(@PathVariable("num") Integer num) { return bookServices.findbookById1(num);}
    @GetMapping("/list3/{num}")//小说
    public PageInfo<book> findbookById3(@PathVariable("num") Integer num ) { return bookServices.findbookById3(num); }
    @GetMapping("/list2/{num2}")//文艺
    public PageInfo<book> findbookById2(@PathVariable("num2") Integer num2 ) { return bookServices.findbookById2(num2); }
    @GetMapping("/list4/{num}")//青春励志
    public PageInfo<book> findbookById4(@PathVariable("num") Integer num ) { return bookServices.findbookById4(num); }
    @GetMapping("/list5/{num}")//人文
    public PageInfo<book> findbookById5(@PathVariable("num") Integer num ) { return bookServices.findbookById5(num); }
    @GetMapping("/list6/{num}")//经管
    public PageInfo<book> findbookById6(@PathVariable("num") Integer num) { return bookServices.findbookById6(num); }
    @GetMapping("/list7/{num}")//教育
    public PageInfo<book> findbookById7(@PathVariable("num") Integer num ) { return bookServices.findbookById7(num); }
    @GetMapping("/list8/{num}")//生活
    public PageInfo<book> findbookById8(@PathVariable("num") Integer num ) { return bookServices.findbookById8(num); }

}
